﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace NQueries.Utils.Test
{
    [TestClass]
    public class MemberInfoExtensionsTest
    {
        public TestContext TestContext { get; set; }

        [TestMethod]
        public void GetAttributeOfTest()
        {
            TestAttribute attribute = typeof(TestClass).GetProperty("Id").GetAttributeOf<TestAttribute>();
            Assert.IsNotNull(attribute);
        }

        [TestMethod]
        public void GetAttributeOfFailedTest()
        {
            TestAttribute attribute = typeof(TestClass).GetProperty("NotId").GetAttributeOf<TestAttribute>();
            Assert.IsNull(attribute);
        }

        #region Nested type: TestAttribute

        public class TestAttribute : Attribute {}

        #endregion

        #region Nested type: TestClass

        public class TestClass
        {
            [Test]
            public int Id { get; set; }

            public int NotId { get; set; }
        }

        #endregion
    }
}